// api统一管理
import $m from './ajax'
import $mockm from './mockAjax'

// 三级联动接口 ：/api/product/getBaseCategoryList  get 无参数
export const reqCategoryList = () => {
    // 发请求 (因为在二次封装axios的时候配置了基本路由"/api"，所以在此url中省略"/api")
    // axios发送请求返回的结果是一个promise对象。
    return $m({ url: '/product/getBaseCategoryList', method: "get" })
}
// 简写：
// export const reqCategoryList = () => $m({ url: '/product/getBaseCategoryList', method: "get" })

// search的数据
export const reqSearchData = (params) => $m({ url: '/list', method: "post", data: params })

// 商品详情信息
export const reqGoodsInfo = (params) => $m({ url: `/item/${params}` })

// 添加到购物车（可以改变购物车中已有的某个物品的数量）
export const reqAddShopping = (skuId, skuNum) => $m({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })

// 获取购物车数据
export const reqCartList = () => $m({ url: '/cart/cartList', method: "get" })

// 删除购物车商品
export const reqDeleteCartById = (skuId) => $m({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })

// 切换商品选中状态
export const reqCheckedCart = (skuId, isChecked) => $m({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: "get" })

// 获取验证码
export const reqGetCode = (phone) => $m({ url: `/user/passport/sendCode/${phone}`, method: "get" })

// 注册用户
export const reqRegister = (data) => $m({ url: `/user/passport/register`, data, method: "post" })

// 用户登录
export const reqUserLogin = (data) => $m({ url: `/user/passport/login`, data, method: "post" })

// 获取用户信息（需要token）
export const reqUserInfo = () => $m({ url: '/user/passport/auth/getUserInfo', method: "get" })

// 退出登录
export const reqLogOut = () => $m({ url: '/user/passport/logout', method: 'get' })

// 获取商品清单和用户地址信息
export const reqSettleAccounts = () => $m({ url: '/order/auth/trade', method: 'get' })

// 提交订单
export const reqSubmitOrder = (tradeNo, data) => $m({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: 'post' })

// 获取支付信息
export const reqPayInfo = (orderId) => $m({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' })

// 获取支付结果
export const reqStatus = (orderId) => $m({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' })

// 我的订单数据
export const reqMyOrder = (page, limit) => $m({ url: `/order/auth/${page}/${limit}`, method: 'get' })

// mock模拟数据的请求
// 轮播图
export const reqGetBannerList = () => $mockm({ url: '/banners', method: "get" })

// floor
export const reqGetFloorData = () => $mockm.get("/floors")

